package com.victor.system.api.factory;

import com.victor.system.api.RemoteDictionaryService;
import com.victor.common.core.domain.R;
import com.victor.common.entity.system.SysDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 *
 */
@Component
public class RemoteDictionaryFallbackFactory implements FallbackFactory<RemoteDictionaryService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteDictionaryFallbackFactory.class);

    @Override
    public RemoteDictionaryService create(Throwable throwable)
    {
        log.error("字典数据调用失败:{}", throwable.getMessage());
        return new RemoteDictionaryService()
        {

            @Override
            public R<List<SysDictionary>> listByFieldName(String fieldName, String source) {
                return null;
            }

            @Override
            public R<SysDictionary> getByFieldNameAndCode(String fieldName, String code, String source) {
                return null;
            }

        };
    }
}
